package com.example.calender;

import android.app.Application;
import android.content.Context;

import androidx.room.Room;

import com.example.calender.persistence.UsersDatabase;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * Create by Snooker on 2020/8/20
 * Describe:
 */
public class BaseApplication extends Application {

    private static BaseApplication application;

    private Context context;

    private ScheduledThreadPoolExecutor executorService  = null;

    private UsersDatabase userDB;

    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        application=this;
        executorService = new ScheduledThreadPoolExecutor(4);
        userDB = Room.databaseBuilder(context,
                UsersDatabase.class, "Calender.db")
                .build();

    }

    public static BaseApplication getInstance(){
        return application;
    }

    public ScheduledThreadPoolExecutor getThreadPool() {
        return executorService;
    }

    public Context getAppContext() {
        return context;
    }

    public UsersDatabase getUserDB(){
        return userDB;
    }
}
